import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

/**
 * @author zhu
 * @date 2024-04-10
 */
public class MainTest {
    public static void print(Student student,
                             Consumer<Student> consumer1,
                             Consumer<Student> consumer2,
                             Consumer<Student> consumer3) {
        consumer1.andThen(consumer2).andThen(consumer3).accept(student);
    }
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        students.add(new Student("大傻椿", 20));
        students.add(new Student("黑佬", 19));
        students.add(new Student("李四", 17));

        for (Student student : students) {
            print(student,(s) -> {
                if (student.getName().startsWith("李")) {
                    System.out.println("姓名以李开头的学生信息：" + student.getName() + ", " + student.getAge() + "岁");
                }
            },(s) -> {
                if (student.getName().length() == 3) {
                    System.out.println("名字有三个字的学生信息：" + student.getName() + ", " + student.getAge() + "岁");
                }
            },(s) -> {
                if (student.getAge() > 18) {
                    System.out.println("年龄大于18岁的学生信息：" + student.getName()  + ", " + student.getAge() + "岁");
                }
            });
        }
    }
}
